package com.clementheliou.cheliou.business.technical.security.authentication;

import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.clementheliou.cheliou.business.technical.security.authentication.model.AuthenticationDetails;

/**
 * Interface of the service used to manage core data about the authenticated
 * user.
 * 
 * @author Clément HELIOU (clement.heliou@gmail.com)
 * @see {@link UserDetailsService}.
 * @since 1.0
 */
public interface AuthenticationDetailsTechnicalService extends UserDetailsService {

	/**
	 * Gets the connected user details. If there is no connected user, an empty
	 * object will be returned. As the returned object can be used in
	 * controllers and views, we don't want to expose the user password inside
	 * it.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @return the connected user details.
	 * @see {@link AuthenticationDetails}.
	 * @since 1.0
	 */
	AuthenticationDetails getCurrentUser();

	/**
	 * Loads the user by its email. In this implementation, the search performed
	 * with the email is case sensitive. Technicaly, this load should be
	 * performed before the authentication attempt.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param email the email of the user we are looking for.
	 * @return the user matching the given email.
	 * @see {@link AuthenticationDetails}.
	 * @since 1.0
	 * @throws UsernameNotFoundException if the user is not found.
	 */
	AuthenticationDetails loadAuthenticationDetailsByEMail(final String email) throws UsernameNotFoundException;
}
